﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class xiaofeichaxun : System.Web.UI.Page
{
    string s_order, s_where;
    protected void Page_Load(object sender, EventArgs e)
    {
        Session["sTittle"] = "财务中心>>消费查询";
        Conn zconn = new Conn();
        string zsql = "select chuzhi from account where username='" + Session["sUsername"].ToString()+"'";
        string zjine = zconn.sqlFirst(zsql);
        lbljine.Text = zjine;
        if(!IsPostBack)
        {
            DataBrid();
            DataBrid2();
        }
    }

    //数据绑定
    private void DataBrid()
    {
        string strWhere = string.Empty;
        if (Session["sJigou"] == null)
        {
            Response.End();
        }
        string zjigou = Session["sJigou"].ToString().Trim();
        string role = Session["sRole"].ToString().Trim();
        string username = Session["sUserName"].ToString();
        switch (role)
        {
            case "学员":
            case "老师":
                strWhere = " where username='" + username + "'";
                break;
            case "机构":
                strWhere = ",account where xiaofei.username=account.username and account.jigou='" + zjigou + "'";
                break;
        }
        int record = 0;
        int count = 0;
        s_order = "ORDER BY xiaofei.id DESC";
        //s_where = " where 1=1";
        string sqlText = " xiaofei.username,xfsj, xfje, topic, topic1";
        DataTable DT = DbHelper.ExecutePage(sqlText, "xiaofei" + strWhere, "xiaofei.id", s_order, Pager.CurrentPageIndex, Pager.PageSize, out record, out count, null);
        Pager.RecordCount = record;
        this.GridView1.DataSource = DT;
        this.GridView1.DataBind();
    }

    protected void pager_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
    {
        Pager.CurrentPageIndex = e.NewPageIndex;
        DataBrid();

    }

    //数据绑定
    private void DataBrid2()
    {
        string strWhere = string.Empty;
        if (Session["sJigou"] == null)
        {
            Response.End();
        }
        string zjigou = Session["sJigou"].ToString().Trim();
        string role = Session["sRole"].ToString().Trim();
        string username = Session["sUserName"].ToString();
        switch (role)
        {
            case "学员":
            case "老师":
                strWhere = " where username='" + username + "'";
                break;
            case "机构":
                strWhere = ",account where chongzhi.username=account.username and account.jigou='" + zjigou + "'";
                break;
        }
        int record = 0;
        int count = 0;
        s_order = "ORDER BY chongzhi.id DESC";
        //s_where = " where 1=1";
        string sqlText = " chongzhi.username,czje, czsj, czsm";
        DataTable DT = DbHelper.ExecutePage(sqlText, "chongzhi" + strWhere, "chongzhi.id", s_order, Pager2.CurrentPageIndex, Pager2.PageSize, out record, out count, null);
        Pager2.RecordCount = record;
        this.GridView2.DataSource = DT;
        this.GridView2.DataBind();
    }

    protected void pager_PageChanging2(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
    {
        Pager2.CurrentPageIndex = e.NewPageIndex;
        DataBrid2();

    }
}
